﻿function goBack() {
    location.href = '/Library/Index';
}
function SubData() {
    var postData = {
        LibraryName: $("#Libraryname").val().trim(),
        LibraryID: $('#hidLibraryId').val(),
        CreateTime: $("#hidCreateTime").val(),
        CreateUserID: $('#hidCreateUserID').val(),
        IsActive: $("#PIsActive").val(),
        Remark: HtmlUtil.htmlEncodeByRegExp(CKEDITOR.instances.desTextarea.getData())
    };
    // Use Ajax to submit form data
    $.post("/Library/Updateinfo", postData, function (result) {
        if (result == "suc") {
            goBack();
        }
        else if (result == "repeat") {
            $.alert({
                title: '系统提示',
                content: '重复数据无法保存！',
                confirm: function () {
                }
            });
        }
        else if (result == "nouser") {
            location.href = '/Login/Index';
        }
        else {
            $.alert({
                title: '系统提示',
                content: '操作失败',
                confirm: function () {
                }
            });
        }
    });
}
$(document).ready(function () {

    CKEDITOR.replace('desTextarea', {
        toolbar: 'Basic'
        //uiColor: '#9AB8F3'//界面颜色
    });
    CKEDITOR.instances.desTextarea.setData(HtmlUtil.htmlDecodeByRegExp($('#hidCom').val()));

    $('#UpdateForm')
      .bootstrapValidator({
          message: 'This value is not valid',
          feedbackIcons: {
              valid: 'glyphicon glyphicon-ok',
              invalid: 'glyphicon glyphicon-remove',
              validating: 'glyphicon glyphicon-refresh'
          },
          fields: {
              Libraryname: {
                  message: 'The Library Name is not valid',
                  validators: {
                      notEmpty: {
                          message: 'The Library Name is required and can\'t be empty'
                      }
                  }
              }

          }
      })
      .on('success.form.bv', function (e) {
          e.preventDefault();
          SubData();
      });
});
